#!/usr/bin/env python

import inkex,simplestyle
import simpleclass
import clean_style
from OrigamiHelper import stylist

class Stylist(inkex.Effect):
    """Remove style attributes when an attribute class exist"""
    def __init__(self):
        """ main stream"""
        inkex.Effect.__init__(self)
        self.OptionParser.add_option("-b", "--book",
                        action="store", type="string",
                        dest="book", default="",
                        help="Style type")        
        self.OptionParser.add_option("-s", "--style",
                        action="store", type="string",
                        dest="style", default="",
                        help="Style type")
                        
    def effect(self) :
        """select all nodes in the selection and  """
        for id, node in self.selected.iteritems():
            self.changeClass(node)
            node = clean_style.cleanStyle(node)


    def changeClass(self, node) :
        """Change the class with the selected style"""        
        node.attrib["class"] =  simpleclass.format(stylist.classes[(self.options.style)])
        # else raise Error ?
        
        

# Create effect instance and apply it.
Effect = Stylist()
Effect.affect()